<%@page import="com.rivercloud.entity.UserVo"%>
<%@page import="java.util.List"%>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- alan_18.2.7 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>模板管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="${base}/css/bootstrap.css">
<link href="${base}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<!-- Sweet Alert -->
<link href="${base}/css/plugins/sweetalert/sweetalert.css"
	rel="stylesheet">
<link href="${base}/css/animate.css" rel="stylesheet">

<script type="text/javascript" src="${base}/js/jquery-3.1.0.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.js"></script>
<script src="${base}/js/content.js?v=1.0.0"></script>
<!-- Sweet alert -->
<script src="${base}/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${base}/js/plugins/layer/layer.min.js"></script>
</head>

<body>
	<div class="container">
		<jsp:include page="${path}/menu.jsp"></jsp:include>
		<div style="margin-left: 20px;margin-bottom: 10px; color: grey">当前位置：模板管理 </div>
		
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span12">

					<!-- alan_18.2.7_start_update_style -->
					<table class="table table-striped table-bordered table-hover dataTables-example">
						<thead>
							<tr bgcolor="#9BCD9B">
								<th>模板名</th>
								<th>创建人</th>
								<th>创建时间</th>

								<th>模板描述</th>
							</tr>
						</thead>
						<tbody>
							<%-- 	<c:forEach items="${projects}" var="project">

								<tr class="tr">
									<td><a href="#">${project.projectName}</a></td>
									<td>${project.projectManager}</td>
									<td><a href="${base}/excel/read?filename=${filename}">
											<button type="button" class="btn btn-primary">添加项目组成员</button>
									</a></td>
									<td><a href="${base}/excel/read?filename=${filename}">
											<button type="button" class="btn btn-primary">delete</button>
									</a></td>
								</tr>
							</c:forEach> --%>
							<c:set var="a" value="1"></c:set>
							<c:forEach items="${templateList}" var="template" >
								<tr class="gradeX">
									<%-- <td><a href="${pageContext.request.contextPath}/template.jsp">${template.templateName }</a></td> --%>
									<td ><a id="template${a}" 
										href="${pageContext.request.contextPath}/tpl/template?templateId=${template.id}">${template.templateName }</a></td>
									<td>张三</td>
									<td>
										<fmt:formatDate type="both" dateStyle="short" timeStyle="short" value="${template.createDate}" />
										<!-- alan_18.2.7_end_update_style -->
									</td>

									<td>
										</td>
								</tr>
								<c:set var="a" value="${a+1}"></c:set>
							</c:forEach>
							<!-- <tr>
								<td>清单模板</td>
								<td>张三</td>
								<td>2017-11-2</td>
								<td><button type="button"
										class="btn btn-danger btn-sm delete">delete</button></td>
							</tr>
							<tr>
								<td>汇总模板</td>
								<td>张三</td>
								<td>2017-11-2</td>
								<td><button type="button"
										class="btn btn-danger btn-sm delete">delete</button></td>
							</tr> -->
						</tbody>
					</table>
					<div>
								<c:set scope="page" value="manager" var="pagein"></c:set>
								<!-- 为每个要判断的按钮或者功能定义一个变量，对应数据库后台的权限表中的keyword字段 -->
							 <% 
								  String pageDelete=(String)pageContext.getAttribute("pagein");
								  //然后改变这里取出来
								  System.out.print(pageDelete);
								  UserVo userVo=(UserVo)session.getAttribute("userVo");
								 
								  if(userVo != null){
									  
								  
								  String keyword=userVo.getrKeyword();
								
								  
								 String [] keywords=keyword.split(",");
									  Boolean flag=false;
									 
										  flag=keyword.equals(pageDelete);//这里改变，最后就能实现了
									  
									  System.out.println(userVo.getuName()+"权限为："+flag);
									   if(flag){
								%>
						<a href="${base}/tpl/addTemplate"><input type="button"
							class="btn btn-success" value="新建模板"></a> 
							<%-- <a href="${base}/uploadTemplate.jsp"><input type="button"
							class="btn btn-success" value="上传模板"></a> --%>

							<% 	
							 				}
								  }
							
						 				%>
						 				
				

					</div>

				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	
/* 	function showTemplate(obj){
	    layer.open({
	      type: 2,
	      title: 'iframe父子操作',
	      maxmin: true,
	      shadeClose: true, //点击遮罩关闭层
	      area : ['800px' , '820px'],
	      content: 'http://127.0.0.1:8082/Excel/tpl/showTemplate?templateId='+obj
	      
	    });
	  }*/
	  
	  function tiaose(){
		    layer.open({
		      type: 2,
		      title: 'iframe父子操作',
		      maxmin: true,
		      shadeClose: true, //点击遮罩关闭层
		      area : ['800px' , '820px'],
		      content: 'http://127.0.0.1:8082/Excel/index3333.html',
		      /*  content: 'http://baidu.com' */
		    	 
		      
		    });
		  };
	
		  
		  
		  
		  
		  
	
	$('.delete').click(function() {
		swal({
			title : "您确定要删除该模板吗",
			text : "删除后将无法恢复，请谨慎操作！",
			type : "warning",
			showCancelButton : true,
			confirmButtonColor : "#DD6B55",
			confirmButtonText : "删除",
			closeOnConfirm : false
		}, function() {

			swal("删除成功！", "您已经删除了该模板。", "success");

		});
	});

	
</script>
</html>


